package com.rd.student.dashuju.zhengchengxiang.July13th.Test;


import java.util.LinkedList;

public class Avg extends Student  {
    private String name;
    private int age;
    public Avg(String name, String major, int classes, int age, String describe, int codeNum) {
        super(name, major, classes, age, describe, codeNum);
    }
    /*
        7、计算成员的平均年龄
        先返回平均值
        再按照降序返回所有成员，只返回成员的名字和年龄，不返回全部信息
        最后按照升序返回所有成员
     */

    public static int avg(LinkedList list) {

        int averageAge = 0;
        for (int i = 0; i < list.size(); i++) {
            Student student = (Student) list.get(i);
            averageAge += student.getAge();
        }
        return averageAge /= list.size();
    }


//    @Override
//    public int compareTo(Object o) {
//        Student o1 =  (Student)o;
//        return o1.getAge() - this.getAge();
//    }
//
//    @Override
//    public String toString() {
//        return "Student{" +
//                "name='" + name + '\'' +
//                ", age=" + age +
//                '}';
//    }
}
